package com.hao.wms.dao.impl;

import com.hao.wms.dao.IEmployeeDao;
import com.hao.wms.domain.Employee;
import org.hibernate.Session;

import java.util.List;

public class EmployeeDaoImpl extends GenericDaoImpl<Employee> implements IEmployeeDao {
	@SuppressWarnings("all")
	@Override
	public Employee login(String name, String password) {
		Session session = sessionFactory.getCurrentSession();
		List<Employee> emps = session.createQuery("select e from Employee e where e.name=? and e.password=?")
				.setParameter(0, name).setParameter(1, password).list();
		if(emps.size()==1) {
			return emps.get(0);
		}
		return null;
	}

}
